﻿<%@ Page Title="" Language="C#" MasterPageFile="~/site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Culture="auto" UICulture="auto" %>

<%@ Register src="UserControls/UCProductsHistory.ascx" tagname="UCProductsHistory" tagprefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <script type="text/javascript" src="<%=ResolveUrl("~/Scripts/swfobject.js") %>"></script>
    <script type="text/javascript" src="<%=ResolveUrl("~/Scripts/jquery.ae.image.resize.min.js") %>"></script>
    <script type="text/javascript">
        $(function () {

            //品牌目录
            var categories = $(".categories");
            var categories_wrapper = $(".categories_wrapper");
            //loading...
            var loading = $('<img alt="loading..." src="<%=ResolveUrl("~/images/loading.gif") %>" />');
            loading.prependTo(categories);

            categories.find(".error").remove();
            var error = $('<span class="error">加载品牌信息出错!</span>');

            function bindBrands() {
                var request = $.ajax({
                    url: '<%=ResolveUrl("~/handlers/BrandHandler.ashx") %>',
                    type: "POST",
                    data: {},
                    dataType: "json",
                    success: function (data) {
                        var ul = '<ul class="categories_inner">',
                        ul_end = '</ul>',
                        btn = '<a class="categories_prev btn"></a><a class="categories_next btn"></a><a class="categories_collapse btn"><img src="images/categories_collapse_up.jpg" /></a>',
                        divs = '';

                        if (data.length > 0) {
                            $.each(data, function (key, val) {
                                if ((key + 1) % 3 != 0) {
                                    divs += '<div><a href="Brands/' + val.BrandID + '">' + $.utility.encode(val.BrandName) + '</a></div>';
                                }
                                else {
                                    divs += '<div><a href="Brands/' + val.BrandID + '">' + $.utility.encode(val.BrandName) + '</a></div>';
                                    ul += '<li class="column">' + divs + '</li>';
                                    divs = '';
                                }
                            });
                            if (divs != '') {
                                ul += '<li class="column">' + divs + '</li>';
                            }
                            //carouFredSel
                            categories.empty().append(ul + ul_end).animate({ height: 140 }, function () {
                                categories_wrapper.append(btn);
                                categories.find(".categories_inner").carouFredSel({
                                    width: 950,
                                    items: {
                                        visible: 5,
                                        width: 190,
                                        height: 140
                                    },
                                    auto: { pauseOnHover: "resume", duration: 700 },
                                    prev: { button: $(".categories_prev") },
                                    next: { button: $(".categories_next") }
                                });
                            });
                        }
                        else {
                            error.text("目前还没有品牌信息，敬请期待...").prependTo(categories);
                        }
                        loading.remove();
                    },
                    error: function (jqXHR, textStatus) {
                        loading.remove();
                        error.prependTo(categories);
                    }
                });
            }
            bindBrands();

            $(".categories_collapse").live("click", function () {
                if (categories.height() != 16) {
                    categories_wrapper.find('a.categories_prev').remove();
                    categories_wrapper.find('a.categories_next').remove();
                    categories_wrapper.find('a.categories_collapse').remove();
                    categories.empty().animate({ height: 16 }).append('<a class="categories_collapse btn" style="bottom:0;"><img src="images/categories_collapse_down.jpg" /></a>');
                }
                else {
                    bindBrands();
                }
            });

            //拼图
            var request = $.ajax({
                url: '<%=ResolveUrl("~/handlers/GalleryHandler.ashx") %>',
                type: "POST",
                data: {},
                dataType: "json",
                success: function (data) {
                    var _photos = [];
                    $(data).each(function (i, v) {
                        var _pic = v.PicName.replace("~/", "");
                        _photos.push({ src: '<%=ResolveUrl("' + _pic + '") %>', url: v.Url });
                    });
                    $("#gallery").photowall({
                        width: 322,
                        height: 322,
                        photos: _photos
                    });
                },
                error: function (jqXHR, textStatus) {
                }
            });


            //新到商品
            $("#newproducts").carouFredSel({
                width: 970,
                height: 278,
                items: {
                    visible: 3,
                    width: 970,
                    height: 94
                },
                scroll: {
                    items: 1,
                    duration: 500,
                    easing: 'linear',
                    fx: 'uncover-fade',
                    queue: true
                },
                direction: 'up',
                circular: true,
                infinite: false,
                auto: { pauseOnHover: "resume", duration: 700 },
                prev: { button: $(".newproduct_up") },
                next: { button: $(".newproduct_down") }
            });

            //商品类型types
            var el_types = $(".types"),
                timeout;
            el_types.mouseenter(function () {
                timeout = setTimeout(function () {
                    el_types.animate({ height: el_types.find(".types_inner").height() });
                }, 1000);
            }).mouseleave(function () {
                clearTimeout(timeout);
                el_types.animate({ height: 60 });
            });

            //生成微博分享按钮
            function weibo(el, title) {
                var _w = 106, _h = 24;
                var param = {
                    url: location.href,
                    type: '5',
                    count: '', /**是否显示分享数，1显示(可选)*/
                    appkey: '', /**您申请的应用appkey,显示分享来源(可选)*/
                    title: title, /**分享的文字内容(可选，默认为所在页面的title)*/
                    pic: '', /**分享图片的路径(可选)*/
                    ralateUid: '', /**关联用户的UID，分享微博会@该用户(可选)*/
                    language: 'zh_cn', /**设置语言，zh_cn|zh_tw(可选)*/
                    rnd: new Date().valueOf()
                }
                var temp = [];
                for (var p in param) {
                    temp.push(p + '=' + encodeURIComponent(param[p] || ''))
                }
                el.append($('<iframe id="weibo" allowTransparency="true" frameborder="0" scrolling="no" src="http://hits.sinajs.cn/A1/weiboshare.html?' + temp.join('&') + '" width="' + _w + '" height="' + _h + '" style="float:right;position:relative;top:1px;"></iframe>'));
            }
            weibo($("#productlist_title"), '');


            //ellipsis
            $.utility.ellipsis({ selector: ".product .info p a", length: 30 });

            //显示&隐藏商品状态
            $(".product .pic").mouseenter(function () {
                $(this).find(".status").hide();
            }).mouseleave(function () {
                $(this).find(".status").fadeIn();
            });

            //圆角
            addEvent(window, 'load', initCorners);

            function initCorners() {
                var tag_settings = {
                    tl: { radius: 15 },
                    tr: { radius: 15 },
                    bl: { radius: 15 },
                    br: { radius: 15 },
                    antiAlias: true
                };

                curvyCorners(tag_settings, ".newproducts");

            }
            //历史
            $(".history .pic").find("img").aeImageResize({ height: 155, width: 155 });

            $(".pngfixer").pngfixer({ shim: 'images/blank.gif' });
        });

        $(window).load(function () {
        });

        window.onload = function () {

        };
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnableHistory="true" OnNavigate="ScriptManager1_Navigate" EnableScriptGlobalization="true" EnableScriptLocalization="true" AsyncPostBackTimeout="36000">
    </asp:ScriptManager>
    <!--品牌分类-->
    <div class="categories_wrapper">
        <div class="categories block">
        </div>
    </div>
    <!--Gallery-->
    <div id="gallery" class="gallery block"></div>
    <!--新品到货-->
    <div class="newproducts block">
        <ul id="newproducts">
            <li class="clearfix">
                <asp:Repeater ID="rptNews" runat="server">
                    <ItemTemplate>
                        <div class="newproduct">
                            <a class="pic" href='<%#ResolveUrl("~/News/"+Eval("ID").ToString()) %>'><img src='<%#ResolveUrl(Eval("Pic").ToString()) %>' border="0" width="111" height="74" /></a>
                            <div class="info">
                                <p class=""><a href='<%#ResolveUrl("~/News/"+Eval("ID").ToString()) %>'><%#HttpUtility.HtmlEncode(Eval("Title").ToString())%></a></p>
                            </div>
                        </div>
                        <%# ((Container.ItemIndex + 1) % 2 == 0) ? "</li><li>" : ""%>
                    </ItemTemplate>
                </asp:Repeater>
            </li>
        </ul>
        <a href="#" class="newproduct_up btn"></a>
        <a href="#" class="newproduct_down btn"></a>
    </div>
    <!--商品类别-->
    <div class="types block">
        <ul class="types_inner clearfix">
            <asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <li><asp:LinkButton ID="lbtnTypeAll" runat="server" onclick="lbtnTypeAll_Click" ForeColor="White">全部</asp:LinkButton></li>
                    <asp:Repeater ID="rptTypes" runat="server" onitemcommand="rptTypes_ItemCommand" 
                        onitemdatabound="rptTypes_ItemDataBound">
                        <ItemTemplate>
                            <li><asp:LinkButton ID="lbtnType" runat="server" CommandName="TYPE_CHANGE" CommandArgument='<%#Eval("TypeID").ToString() %>'><%#HttpUtility.HtmlEncode(Eval("TypeName").ToString())%></asp:LinkButton></li>
                        </ItemTemplate>
                    </asp:Repeater>
                </ContentTemplate>
            </asp:UpdatePanel>
        </ul>
    </div>
    <!--商品列表-->
    <h1 id="productlist_title" class="title">
        <span><asp:Localize ID="Localize1" Text='<%$ Resources: ResourceGlobal, Brand_NewProducts_Title  %>' runat="server"></asp:Localize></span>
        <a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=173860283&site=qq&menu=yes" class="float_r"><img border="0" src="http://wpa.qq.com/pa?p=2:173860283:41" alt="点击这里给我发消息" title="点击这里给我发消息"></a>
    </h1>
    <div class="clearfix">
        <div class="productlist_wrap">
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <script type="text/javascript">
                        Sys.Application.add_load(function () {
                            //显示&隐藏商品状态
                            $(".product .pic").mouseenter(function () {
                                $(this).find(".status").hide();
                            }).mouseleave(function () {
                                $(this).find(".status").fadeIn();
                            });
                        });
                    </script>
                    <div class="productlist block clearfix">
                    <asp:Repeater ID="rptProducts" runat="server">
                        <ItemTemplate>
                            <div class="product <%#((Container.ItemIndex+1) % 4 == 0 )? "last" :"" %>">
                                <div class="pic"><i></i><a href='<%#ResolveUrl("~/Products/"+Eval("ProductID").ToString()) %>'><img src='<%#ResolveUrl(Eval("Image174").ToString()) %>' border="0"/></a><span class="status"><img src='<%#GetProductStatus(Convert.ToInt32(Eval("Status"))) %>' /></span></div>
                                <div class="info">
                                    <p><a href='<%#ResolveUrl("~/Products/"+Eval("ProductID").ToString()) %>'><%#HttpUtility.HtmlEncode(Eval("ProductName").ToString())%></a></p>
                                    <%if (System.Globalization.CultureInfo.CurrentCulture.Name.ToLower() == "zh-cn")
                                      { %>
                                        <p><span style='<%#Convert.ToInt32(Eval("SalePrice"))!=0?"text-decoration: line-through;":string.Empty%>'><%#(Convert.ToInt32(Eval("UnitPrice")) != 0) ? string.Format("{0:C}", Eval("UnitPrice")) : Resources.ResourceGlobal.Product_Ask%></span><span class="saleprice"><%#Convert.ToInt32(Eval("SalePrice"))!=0?string.Format("{0:C}",Eval("SalePrice")):string.Empty%></span></p>
                                    <%}
                                      else if (System.Globalization.CultureInfo.CurrentCulture.Name.ToLower() == "en-us")
                                      {%>
                                        <p><span style='<%#Convert.ToInt32(Eval("SalePriceUS"))!=0?"text-decoration: line-through;":string.Empty%>'><%#(Convert.ToInt32(Eval("UnitPriceUS")) != 0) ? string.Format("{0:C}", Eval("UnitPriceUS")) : Resources.ResourceGlobal.Product_Ask%></span><span class="saleprice"><%#Convert.ToInt32(Eval("SalePriceUS"))!=0?string.Format("{0:C}",Eval("SalePriceUS")):string.Empty%></span></p>
                                    <%}
                                      else if (System.Globalization.CultureInfo.CurrentCulture.Name.ToLower() == "ja-jp")
                                      {%>
                                        <p><span style='<%#Convert.ToInt32(Eval("SalePriceJP"))!=0?"text-decoration: line-through;":string.Empty%>'><%#(Convert.ToInt32(Eval("UnitPriceJP")) != 0) ? string.Format("{0:C}", Eval("UnitPriceJP")) : Resources.ResourceGlobal.Product_Ask%></span><span class="saleprice"><%#Convert.ToInt32(Eval("SalePriceJP"))!=0?string.Format("{0:C}",Eval("SalePriceJP")):string.Empty%></span></p>
                                    <%} %>
                                </div>
                            </div>
                        </ItemTemplate>
                    </asp:Repeater>
                    </div>
                    <div class="pager margin10_tb">
                        <asp:Repeater ID="rptPageFliper" runat="server">
                            <ItemTemplate>
                                <span class='<%#(((PageNumberItem)Container.DataItem).IsCurrentPage) ? "current": string.Empty%>'
                                    class="paging">
                                    <asp:LinkButton ID="lbtnPager" runat="server" CommandName="<%# ((PageNumberItem)Container.DataItem).PageNumberCommand%>"
                                        Text="<%# ((PageNumberItem)Container.DataItem).PageNumberText%>" Enabled='<%# !(((PageNumberItem)Container.DataItem).IsCurrentPage) %>'
                                        Font-Underline="false"></asp:LinkButton>
                                </span>
                            </ItemTemplate>
                        </asp:Repeater>
                        <asp:TextBox ID="txtPageNum" runat="server" CssClass="page-to-go"></asp:TextBox>
                        <asp:LinkButton ID="lbtnGo" runat="server" onclick="lbtnGo_Click" CssClass="linkbtn">GO</asp:LinkButton>
                    </div>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="rptTypes" EventName="ItemCommand" />
            </Triggers>
        </asp:UpdatePanel>
        </div>
        <!--右侧-->
        <div class="rightbar block">
            <!--tag clouds-->
            <div class="rightbar_innerblock">
                <div class="brands">
                    <div id="brands-tags"></div>
                </div>
            </div>
            <!--weibo-->
            <div class="rightbar_innerblock">
                <div class="weibo">
                    <iframe width="100%" height="800" class="share_self"  frameborder="0" scrolling="no" src="http://widget.weibo.com/weiboshow/index.php?language=&width=0&height=800&fansRow=3&ptype=1&speed=0&skin=10&isTitle=1&noborder=0&isWeibo=1&isFans=1&uid=247122433&verifier=b4ed5053&dpc=1"></iframe>
                    <%--<iframe width="100%" height="600" class="share_self"  frameborder="0" scrolling="no" src="http://widget.weibo.com/weiboshow/index.php?language=&width=0&height=600&fansRow=2&ptype=1&speed=0&skin=10&isTitle=1&noborder=0&isWeibo=1&isFans=1&uid=1820688827&verifier=9cc7a120&colors=010202,0f0f0f,eeeeee,eeeeee,191b1b&dpc=1"></iframe>--%>
                </div>
            </div>
            <asp:Repeater ID="rptAds" runat="server">
                <ItemTemplate>
                    <div class="rightbar_innerblock">
                        <a href='<%#ResolveUrl(Eval("Url").ToString()) %>' target="_blank"><img src='<%#ResolveUrl(Eval("Image").ToString()) %>' width="100%" border="0" alt='<%#Eval("AdName").ToString() %>' /></a>
                    </div>
                </ItemTemplate>
            </asp:Repeater>
        </div>
    </div>
    <!--最近浏览-->
    <uc1:UCProductsHistory ID="UCProductsHistory1" runat="server" />
    
    <script type="text/javascript">
        //tag clouds
        var so = new SWFObject("Scripts/tagcloud/tagcloud.swf", "brands-tags", "250", "241", "7", "#0f0f0f");
        // uncomment next line to enable transparency
        //so.addParam("wmode", "transparent");
        so.addVariable("tcolor", "0x333333");
        so.addVariable("tcolor2", "0xeeeeee");
        so.addVariable("hicolor", "0xffffff");
        so.addVariable("mode", "tags");
        so.addVariable("distr", "true");
        so.addVariable("tspeed", "100");
        so.addVariable("tagcloud", "<%=GetTagsXML() %>");
        so.write("brands-tags");
	</script>
</asp:Content>

